/**
 * Created by WB on 2017/3/20.
 */
var app = angular.module('myApp', ['ui.bootstrap', 'oc.lazyLoad', 'angular-loading-bar', 'ngAnimate', 'ngTouch', 'services', 'routers', 'filters', 'components', 'config']);

app.config(["$provide", "$compileProvider", "$controllerProvider", "$filterProvider",
	function ($provide, $compileProvider, $controllerProvider, $filterProvider) {
		app.controller = $controllerProvider.register;
		app.directive = $compileProvider.directive;
		app.filter = $filterProvider.register;
		app.factory = $provide.factory;
		app.service = $provide.service;
		app.constant = $provide.constant;
	}]);

app.run(['$rootScope', 'router_state',
	function($rootScope, router_state){
		$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams){
			router_state.state = toState.name;
			$rootScope.router_state = toState.name;
			switch (router_state.state){
				//nav1.html
				case 'organization':
					$rootScope.nav_url = './app/template/nav1.html';
					$rootScope.donghua = false;
					break;
				case 'person_base_info':
					$rootScope.nav_url = './app/template/nav1.html';
					$rootScope.donghua = false;
					break;
			}
		});
		navSelected = function(id,flag){
			$rootScope.donghua = flag;
			setTimeout(function () {
				$("#"+id).addClass("select_nav").siblings().removeClass("select_nav");
				if($("#"+id).siblings().find("span").hasClass("select_nav")){
					$("#"+id).siblings().find("span").removeClass("select_nav");
				}
				if($("#"+id).parent().siblings().hasClass("select_nav")){
					$("#"+id).parent().siblings().removeClass("select_nav");
				}
			}, 100);
		}
	}]);

app.controller('indexController', ['$scope', '$state', '$rootScope', function($scope, $state, $rootScope){
	$rootScope.navList=[
		{'name':'课程列表','url':'courseList'},
		{'name':'教师信息管理','url':'teacherInfo'},
		{'name':'教室信息管理','url':'classroomInfo'},
		{'name':'学生信息管理','url':'studentInfo'},
		{'name':'系统设置','url':'systemSetting'}
		]
	}]);